<template>
	<view class="login-container">
		<view class="login-form">
			<text class="title">登录</text>
			<view class="input-item">
				<input type="text" v-model="username" placeholder="请输入账号或用户名" />
			</view>
			<view class="input-item">
				<input type="password" v-model="password" placeholder="请输入密码" />
			</view>
			<button class="login-btn" @click="handleLogin">登录</button>
			<navigator url="/pages/components/register/register" class="register-link">没有账号?注册</navigator>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username: '',
				password: ''
			};
		},
		methods: {
			handleLogin() {
				if (this.username === 'hhl' && this.password === '123456') {
					uni.showToast({
						title: '登陆成功',
						icon: 'none'
					})
					setTimeout(() => {
						uni.setTabBarItem({
							index: 3, 
							text: '我的', 
							iconPath: '/static/tab/my.png',
							selectedIconPath: '/static/tab/my.png'
						})
					}, 300)

					uni.switchTab({
						url: '/pages/TabBar/tabcompage/tabcompage'
					})
				} else {
					uni.showToast({
						title: '账号或密码错误',
						icon: 'none'
					})
				}
			}
		}
	};
</script>

<style>

</style>